fix(installer): stop PS 5.1 stderr wrapping from aborting version probes - #1255
fix(installer): stop PS 5.1 stderr wrapping from aborting version probes#1255MasterFede5 wants to merge 1 commit into
Conversation
install.ps1 sets $ErrorActionPreference = "Stop" globally, but Windows PowerShell 5.1 (the default powershell.exe the README instructs users to run) wraps redirected native stderr lines in ErrorRecords. The two '--version 2>&1' probes therefore treat any healthy binary that prints a warning to stderr (exit code 0) as a fatal error and abort the install. Relax EAP to Continue only around the two native probe calls, restoring it in a finally block; failure detection remains on $LASTEXITCODE. Reproduced on PS 5.1.26100.8875 with a stub that prints a version to stdout, one warning line to stderr, and exits 0: the previous pattern aborts, the new pattern captures the version and still detects nonzero exits. tests/test_windows_bundle_contract.sh passes (the literal '& $DownloadedLauncher --version' invariant is preserved). Signed-off-by: MasterFede5 <friedrickms@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: MasterFede5 <friedrickms@gmail.com>
|
Thanks for this, and sorry for the delayed acknowledgement. Queued for review. A +19/-2 single-file change is easy to review — nothing blocking from a size standpoint. CI shows 1-2 failing checks worth checking while it waits. PowerShell 5.1 wrapping stderr and thereby aborting verification is a nasty class of bug: it makes a working install look broken for reasons that have nothing to do with the install. Good catch. |
|
Great catch, and a textbook writeup. The hazard is real and still live on current main — I verified it rather than taking your word for it: That is exactly the kind of latent installer bomb that only detonates the day the binary prints its first warning, and with the daemon work adding warning paths it is a plausible one. Your scoped Thank you for the pure-ASCII discipline. I byte-scanned the patch and it is clean, comments deliberately avoiding em-dashes. We have been burned by a single non-ASCII character in this exact file before — PowerShell 5.1 decodes a BOM-less Three things needed, all small: 1. A mechanical rebase. Main removed the launcher stub ( 2. One hardening ask — a narrow false-pass window. With Pre-seeding 3. Yes please to the test you offered. You mentioned you would add a harness test if pointed at the right place: a stderr-writing stub under the Windows VM With the rebase and the pre-seed this merges. Thanks for a precise, well-scoped fix. |
What does this PR do?
Fixes a Windows PowerShell 5.1 failure mode in
install.ps1: the script sets$ErrorActionPreference = "Stop"globally, and PS 5.1 (the defaultpowershell.exethe README instructs users to run) wraps redirected native stderr in ErrorRecords. The two--version 2>&1probes (candidate at ~L265, installed binary at ~L288) therefore abort the whole install for any healthy binary that prints a single warning line to stderr while exiting 0 — reportingerror: downloaded binary failed to run.The fix relaxes EAP to
Continueonly around the two native probe calls, restoring it in afinallyblock. Failure detection is unchanged: it stays on$LASTEXITCODE.Reproduction (PS 5.1.26100.8875,
powershell.exe -File): stub binary printing a version to stdout + one warning to stderr, exit 0 → previous pattern aborts with the stderr text as the exception; new pattern captures the version output and still detects a nonzero exit (tested with exit 3). EAP is restored toStopafterwards.The literal invariants checked by
tests/test_windows_bundle_contract.sh(& $DownloadedLauncher --version, launcher-only invocation) are preserved — that contract test passes locally.Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test) — not run: no C toolchain on this machine; the change touches onlyinstall.ps1.tests/test_windows_bundle_contract.sh(the suite that asserts installer invariants) passes locally.make -f Makefile.cbm lint-ci) — C linters not applicable to this script-only change;install.ps1parses clean (PSParser, 0 errors).🤖 Generated with Claude Code